import dotenv from 'dotenv';
import { IConfig, IEnvVars } from '../types';

dotenv.config();

const env = process.env as IEnvVars;

const config: IConfig = {
  // 服务器配置
  PORT: parseInt(env.PORT || '3000', 10),
  NODE_ENV: env.NODE_ENV || 'development',
  
  // 客户端配置
  CLIENT_URL: env.CLIENT_URL || 'http://localhost:5173',
  
  // JWT 配置
  JWT_SECRET: env.JWT_SECRET || 'your-secret-key-here',
  JWT_EXPIRES_IN: env.JWT_EXPIRES_IN || '24h',
  
  // 数据库配置 (如果需要)
  DB_HOST: env.DB_HOST || 'localhost',
  DB_PORT: parseInt(env.DB_PORT || '5432', 10),
  DB_NAME: env.DB_NAME || 'restful_demo',
  DB_USER: env.DB_USER || 'postgres',
  DB_PASSWORD: env.DB_PASSWORD || '',
  
  // API 配置
  API_PREFIX: '/api',
  API_VERSION: 'v1'
};

export default config;
